<% content_for :sitemap do %>
  <span class="current">
    <%= t('admin.menu.photos') %>
  </span>
<% end %>
<div class="toolbar">
  <form class="form-inline" action="<%= admin_photos_path %>">
    <input type="text" name="login" class="form-control" value="<%= params[:login] %>" placeholder="Username">
    <button class="btn btn-secondary">Search</button>
  </form>
</div>
<div class="photos">
  <% @photos.each do |photo| %>
    <div class="card" id="<%= dom_id(photo) %>">
      <div class="card-img-top">
        <%= link_to image_tag(photo.image.url(:md)), photo.image.url, target: "_blank" if !photo[:image].blank? %>
      </div>
      <div class="card-body">
        <div class="card-text mb-2">
          <% if photo.user %>
            <%= link_to photo.user&.login, edit_admin_user_path(photo.user_id), target: "_blank" %>
          <% end %>
        </div>
        <%= link_to icon_tag("trash", label: "Delete" ), admin_photo_path(photo), 'data-confirm'=> 'Are you sure?',
              method: :delete, remote: true, class: "btn btn-secondary btn-sm btn-block" %>
      </div>
    </div>
  <% end %>
</div>
<%= paginate @photos %>
